```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redis穿透防护解决方案</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .heading-font {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
        }
        .solution-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 0.5rem;
            overflow-x: auto;
        }
        .icon-wrapper {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            margin: 0 auto 1rem;
        }
        .divider {
            height: 1px;
            background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0) 100%);
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="heading-font text-4xl md:text-5xl font-bold mb-6 leading-tight">Redis穿透攻击防护方案</h1>
            <p class="text-xl opacity-90 max-w-3xl mx-auto mb-8">应对非法数据请求导致Redis过载的全面解决方案</p>
            <div class="flex justify-center space-x-4">
                <a href="#solutions" class="bg-white text-blue-600 px-6 py-3 rounded-lg font-medium hover:bg-opacity-90 transition duration-300 shadow-lg">查看解决方案</a>
                <a href="#visualization" class="border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:bg-opacity-10 transition duration-300">可视化分析</a>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 max-w-5xl mx-auto">
        <div class="bg-white rounded-xl shadow-md p-8">
            <h2 class="heading-font text-2xl font-bold mb-4 text-gray-800">什么是Redis穿透攻击？</h2>
            <p class="mb-6 text-gray-700">Redis穿透是一种常见的攻击方式，攻击者通过不断向Redis发送大量非法请求，导致服务器过载、性能下降甚至崩溃。这种攻击会消耗服务器资源，影响正常业务运行。</p>
            
            <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-6">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <svg class="h-5 w-5 text-blue-500" fill="currentColor" viewBox="0 0 20 20">
                            <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path>
                        </svg>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-blue-800">技术要点</h3>
                        <div class="mt-2 text-sm text-blue-700">
                            <p>关键问题在于如何有效识别和拦截非法请求，同时保证合法请求的正常处理。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Solutions Section -->
    <section id="solutions" class="py-16 px-4 sm:px-6 lg:px-8 bg-white">
        <div class="max-w-5xl mx-auto">
            <h2 class="heading-font text-3xl font-bold text-center mb-12 text-gray-800">七种防护策略</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Solution 1 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-blue-100 text-blue-600">
                        <i class="fas fa-filter text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">1. 布隆过滤器</h3>
                    <p class="text-gray-600 mb-4">使用概率型数据结构快速检测元素是否存在，过滤无效请求。</p>
                    
                    <div class="code-block p-4 mb-4">
                        <pre class="text-sm"><code class="language-java">// 使用布隆过滤器检查元素
if (bloomFilter.mightContain(key)) {
    Object value = redis.get(key);
} else {
    // 键不存在
}</code></pre>
                    </div>
                    
                    <ul class="text-gray-600 text-sm space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>内存消耗低，查询效率高</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>有效拦截绝大多数无效请求</span>
                        </li>
                    </ul>
                </div>

                <!-- Solution 2 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-purple-100 text-purple-600">
                        <i class="fas fa-clock text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">2. 合理过期策略</h3>
                    <p class="text-gray-600 mb-4">设置合理的过期时间，自动清除过期数据，避免内存被占满。</p>
                    
                    <div class="code-block p-4 mb-4">
                        <pre class="text-sm"><code class="language-java">// 设置带过期时间的键
redis.set(key, value, "EX", 3600); // 1小时后过期</code></pre>
                    </div>
                    
                    <ul class="text-gray-600 text-sm space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>防止无效数据长期占用内存</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>自动维护缓存新鲜度</span>
                        </li>
                    </ul>
                </div>

                <!-- Solution 3 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-red-100 text-red-600">
                        <i class="fas fa-tachometer-alt text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">3. 请求频率限制</h3>
                    <p class="text-gray-600 mb-4">对客户端IP或应用设置请求频率限制，防止恶意请求。</p>
                    
                    <div class="code-block p-4 mb-4">
                        <pre class="text-sm"><code class="language-java">// 速率限制示例
String key = "rate_limit:" + clientIp;
long count = redis.incr(key);
if (count == 1) redis.expire(key, 60);
if (count > maxRequestsPerMinute) {
    throw new RateLimitException();
}</code></pre>
                    </div>
                    
                    <ul class="text-gray-600 text-sm space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>有效控制单个客户端请求量</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>可灵活调整阈值</span>
                        </li>
                    </ul>
                </div>

                <!-- Solution 4 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-yellow-100 text-yellow-600">
                        <i class="fas fa-shield-alt text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">4. 防火墙与负载均衡</h3>
                    <p class="text-gray-600 mb-4">使用WAF和负载均衡器过滤非法请求，保护Redis服务器。</p>
                    
                    <div class="space-y-3 mb-4">
                        <div class="flex items-center text-gray-600">
                            <i class="fas fa-check text-green-500 mr-2"></i>
                            <span>Web应用防火墙(WAF)阻挡恶意流量</span>
                        </div>
                        <div class="flex items-center text-gray-600">
                            <i class="fas fa-check text-green-500 mr-2"></i>
                            <span>IP黑名单拦截已知攻击源</span>
                        </div>
                    </div>
                    
                    <div class="bg-yellow-50 border-l-4 border-yellow-400 p-3 text-sm text-yellow-700">
                        <p>建议结合云服务商提供的安全服务，如AWS WAF或阿里云WAF，实现高效防护。</p>
                    </div>
                </div>

                <!-- Solution 5 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-green-100 text-green-600">
                        <i class="fas fa-lock text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">5. Redis安全特性</h3>
                    <p class="text-gray-600 mb-4">利用Redis内置的安全功能加强防护。</p>
                    
                    <div class="code-block p-4 mb-4">
                        <pre class="text-sm"><code class="language-bash"># 设置访问控制列表(ACL)
acl setuser myuser on >password ~* +@all</code></pre>
                    </div>
                    
                    <div class="code-block p-4 mb-4">
                        <pre class="text-sm"><code class="language-bash"># 设置Redis密码
requirepass yourpassword</code></pre>
                    </div>
                    
                    <ul class="text-gray-600 text-sm space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>限制不同用户的权限</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>防止未授权访问</span>
                        </li>
                    </ul>
                </div>

                <!-- Solution 6 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300">
                    <div class="icon-wrapper bg-indigo-100 text-indigo-600">
                        <i class="fas fa-chart-line text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">6. 监控与报警</h3>
                    <p class="text-gray-600 mb-4">实时监控Redis性能，及时发现异常情况。</p>
                    
                    <div class="space-y-3 mb-4">
                        <div class="flex items-center text-gray-600">
                            <i class="fas fa-check text-green-500 mr-2"></i>
                            <span>使用Redis MONITOR命令实时监控</span>
                        </div>
                        <div class="flex items-center text-gray-600">
                            <i class="fas fa-check text-green-500 mr-2"></i>
                            <span>设置异常请求模式报警</span>
                        </div>
                    </div>
                    
                    <div class="bg-indigo-50 border-l-4 border-indigo-400 p-3 text-sm text-indigo-700">
                        <p>推荐使用Prometheus+Grafana或阿里云/腾讯云的Redis监控服务。</p>
                    </div>
                </div>

                <!-- Solution 7 -->
                <div class="solution-card bg-white rounded-xl shadow-md p-8 transition duration-300 md:col-span-2">
                    <div class="icon-wrapper bg-pink-100 text-pink-600 mx-auto">
                        <i class="fas fa-layer-group text-2xl"></i>
                    </div>
                    <h3 class="heading-font text-xl font-bold mb-3 text-center">7. 使用缓存穿透防护库</h3>
                    <p class="text-gray-600 mb-4 text-center max-w-2xl mx-auto">利用成熟的缓存库简化防护实现，如Google Guava Cache。</p>
                    
                    <div class="code-block p-4 mb-4 max-w-2xl mx-auto">
                        <pre class="text-sm"><code class="language-java">// 使用Guava Cache示例
Cache&lt;String, Object&gt; cache = CacheBuilder.newBuilder()
    .expireAfterWrite(1, TimeUnit.HOURS)
    .build();

Object value = cache.getIfPresent(key);
if (value == null) {
    value = redis.get(key);
    cache.put(key, value);
}</code></pre>
                    </div>
                    
                    <ul class="text-gray-600 text-sm space-y-2 max-w-2xl mx-auto">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>内置过期策略和缓存管理</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>简化开发，提高代码可维护性</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section id="visualization" class="py-16 px-4 sm:px-6 lg:px-8 bg-gray-50">
        <div class="max-w-5xl mx-auto">
            <h2 class="heading-font text-3xl font-bold text-center mb-12 text-gray-800">防护策略关系图</h2>
            
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="mermaid">
                    graph TD
                        A[Redis穿透攻击] --> B[前端防护]
                        A --> C[Redis层防护]
                        A --> D[架构层防护]
                        
                        B --> B1[布隆过滤器]
                        B --> B2[请求频率限制]
                        
                        C --> C1[合理过期策略]
                        C --> C2[ACL访问控制]
                        C --> C3[密码保护]
                        
                        D --> D1[WAF防火墙]
                        D --> D2[负载均衡]
                        D --> D3[监控报警系统]
                        
                        style A fill:#ef4444,color:white
                        style B fill:#3b82f6,color:white
                        style C fill:#10b981,color:white
                        style D fill:#8b5cf6,color:white
                </div>
            </div>
            
            <div class="mt-12 grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="heading-font font-bold text-lg mb-3 text-gray-800">防御层级分析</h3>
                    <p class="text-gray-600 text-sm">Redis防护需要多层次防御体系，从前端请求过滤到后端安全配置，形成完整的防护链条。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="heading-font font-bold text-lg mb-3 text-gray-800">实施优先级</h3>
                    <p class="text-gray-600 text-sm">建议优先部署布隆过滤器和请求限制，再配置Redis安全特性，最后完善监控系统。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="heading-font font-bold text-lg mb-3 text-gray-800">性能影响</h3>
                    <p class="text-gray-600 text-sm">合理配置的防护措施对正常请求影响极小，反而能提升系统整体稳定性。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Best Practices -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-white">
        <div class="max-w-5xl mx-auto">
            <h2 class="heading-font text-3xl font-bold text-center mb-12 text-gray-800">最佳实践建议</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-blue-50 rounded-xl p-8">
                    <h3 class="heading-font text-xl font-bold mb-4 text-blue-800">组合策略</h3>
                    <p class="text-blue-700 mb-6">单一防护措施可能不足以应对复杂攻击场景，建议组合使用多种策略：</p>
                    <ul class="space-y-3 text-blue-700">
                        <li class="flex items-start">
                            <span class="bg-blue-100 text-blue-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">1</span>
                            <span>前端布隆过滤器+请求限制</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-blue-100 text-blue-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">2</span>
                            <span>Redis安全配置+合理过期时间</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-blue-100 text-blue-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">3</span>
                            <span>WAF防火墙+监控报警</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-indigo-50 rounded-xl p-8">
                    <h3 class="heading-font text-xl font-bold mb-4 text-indigo-800">性能调优</h3>
                    <p class="text-indigo-700 mb-6">防护措施应考虑性能影响，建议进行以下优化：</p>
                    <ul class="space-y-3 text-indigo-700">
                        <li class="flex items-start">
                            <span class="bg-indigo-100 text-indigo-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">1</span>
                            <span>布隆过滤器内存占用优化</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-indigo-100 text-indigo-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">2</span>
                            <span>Redis连接池配置</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-indigo-100 text-indigo-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">3</span>
                            <span>监控系统采样率设置</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col items-center">
                <div class="text-2xl font-bold text-white mb-2">技术小馆</div>
                <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300">http://www.yuque.com/jtostring</a>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            securityLevel: 'loose'
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```